package com.thermofisher.dsc.amanda.security.runner;

import com.thermofisher.dsc.amanda.common.util.RsaKeyHelper;
import com.thermofisher.dsc.amanda.security.config.KeyConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * Created by wenjie.yang on 9/28/2018.
 */
@Component
public class AuthServerRunner implements CommandLineRunner {

    @Autowired
    private KeyConfiguration keyConfiguration;

    @Override
    public void run(String... args) throws Exception {
        keyConfiguration.setUserPriKey(RsaKeyHelper.getPrivateKey("classpath:pri.key").getEncoded());
        keyConfiguration.setUserPubKey(RsaKeyHelper.getPublicKey("classpath:pub.key").getEncoded());
        keyConfiguration.setGrowthClickRSAKey(RSAWithThirdParty.getPublicKey("classpath:pub_pkcs8.pem"));
    }
}
